﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace jobsheetFinal
{
    public partial class frmSalesRaiseJS : Form
    {
        public frmSalesRaiseJS()
        {
            InitializeComponent();
        }

        private void SalesRaiseJS_Load(object sender, EventArgs e)
        {

        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            //Page Connection
            this.Hide();
            AllFormClass.SalesMainPage.Show();
        }

        private void btnSubmit_Click(object sender, EventArgs e)
        {
           

        }

        private void btnSubmit_Click_1(object sender, EventArgs e)
        {
            //Get the input
            /*-----SERVICE REQUEST-------*/

            string jobsheetRequest = CboxJSRequest.Text;
            DateTime preferredSiteService = Convert.ToDateTime(dateTimePicker.Text);

            /*-----SERVICE REQUEST-------*/


            /*-------JOBSHEET INFORMATION--------*/

            string jobSheetNumber = tbxJSNo.Text;
            string SO = tbxSONo.Text;
            string ecsPO = tbxPONo.Text;
            string project = tbxProjectName.Text;

            /*--------JOBSHEET INFORMATION--------*/

            /*-------CONTACT INFORMATION---------*/
            //RESELLER
            string reseller = tbxReseller.Text;
            string re_Address = tbxAddress.Text;
            string re_contactPerson = tbxContactPerson.Text;
            int re_mobileNumber = Convert.ToInt32(tbxReMobileTEL.Text);
            string re_emailAddress = tbxEmail.Text;

            //END USER
            string enduser = tbxEndUser.Text;
            string end_address = tbxEnAddress.Text;
            string end_contactPerson = tbxEnContactPeson.Text;
            int end_mobileNumber = Convert.ToInt32(tbxEnMobile.Text);
            string end_email = tbxEnEmail.Text;

            /*-------CONTACT INFORMATION---------*/


            /*-------JOB SCOPE-----------*/

            //string jobsheetRequest = CboxJSRequest.Text;
            // string serviceCode = CbxServiceCode.Text;
          string serviceCode = null;
            {
                if (rbtnSVCHP.Checked ==true)
                {
                    serviceCode = "SVC-MNT-HP";
                }
                else if (rbtnSVCSun.Checked == true)
                {
                    serviceCode = "SVC-MNT-SUN";
                }
 
            }
            string description = Convert.ToString(dataGridJobScope[0, 0].Value);
            int quantity = Convert.ToInt16(dataGridJobScope[1, 0].Value);
            double price = Convert.ToDouble(dataGridJobScope[2, 0].Value);
            string remark= Convert.ToString(dataGridJobScope[3,0].Value);
           
            ServiceRequest r1=new ServiceRequest(jobsheetRequest,preferredSiteService,jobSheetNumber, SO,
                                                  ecsPO, project, reseller,  re_Address,  re_contactPerson,
                                                  re_mobileNumber,  re_emailAddress,  enduser,  end_address,  end_contactPerson,
                                                  end_mobileNumber,  end_email,  serviceCode,  description, quantity,
                                                  price, remark);
            /*-------JOB SCOPE-----------*/


            //Save Jobsheet Info into database
            DBManager.ServiceRequest(r1);
            MessageBox.Show("Submitted Successfully!");
            CboxJSRequest.SelectedItem = null;
            tbxSalesPerson.Clear();
            tbxJSNo.Clear();
            tbxPONo.Clear();
            tbxSONo.Clear();
            tbxProjectName.Clear();
            tbxReseller.Clear();
            tbxAddress.Clear();
            tbxContactPerson.Clear();
            tbxReMobileTEL.Clear();
            tbxEmail.Clear();
            tbxEndUser.Clear();
            tbxEnAddress.Clear();
            tbxEnContactPeson.Clear();
            tbxEnAddress.Clear();
            tbxEnEmail.Clear();
            rbtnSVCHP.Checked = true;
          

            


            //Send alert message to Clifford's email


            //Page connection
        
            this.Hide();
            AllFormClass.SalesMainPage.Show();
        }


    }
}
